// AlarmZ Program for PCMod (SERVER)

PROG.PName = "AlarmZ"
PROG.Author = "[GU]|ZLC|thomasfn"

function PROG:Initialize( pl )
	SendClientProgram( pl, "AlarmZ" )
	SendClientWindow( pl, "Main" )
	
	self:PC_Changed( pl )
end

function PROG:Unload()
	
end

function PROG:Think()

end

function PROG:CommandRecieved( ply, command, args )
	local pc = ply.CurrentPC
	if (!pc) then return end
	if (command == "play") then
		local speaker = pc.Data[ pc:EntIndex() ].Speaker
		if (speaker) then
			speaker:Sound_Play( args[1] )
		else
			BeamData_String( ply, "status", "No sound hardware!" )
		end
		self:CommandRecieved( ply, "getstatus", {} )
	end
	if (command == "stop") then
		local speaker = pc.Data[ pc:EntIndex() ].Speaker
		if (speaker) then
			speaker:Sound_Stop()
		else
			BeamData_String( ply, "status", "No sound hardware!" )
		end
		self:CommandRecieved( ply, "getstatus", {} )
	end
	if (command == "getstatus") then
		local speaker = pc.Data[ pc:EntIndex() ].Speaker
		if (speaker) then
			BeamData_String( ply, "status", speaker:Sound_Get() )
		else
			BeamData_String( ply, "status", "No Speaker Hardware" )
		end
	end
	if (command == "quit") then
		UnloadProgram( ply )
	end
end

function PROG:PC_Changed( ply )
	pc = ply.CurrentPC
	if (!pc) then return end
	PData[pc:EntIndex()].LPlayer = ply
end

function PROG:PacketRecieved( packet, pc )

end